package com.imm.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.imm.common.Result;
import com.imm.dto.OrderDTO;
import com.imm.pojo.Order;
import com.imm.service.IOrderService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Resource
    private IOrderService orderService;


    @GetMapping("/page")
    public Result<Page<OrderDTO>> page(int page, int pageSize, OrderDTO orderDTO) {
        return orderService.pageOrder(page, pageSize, orderDTO);
    }

    @PutMapping
    public Result<String> update(@RequestBody Order order) {
        return orderService.updateOrder(order);
    }


    @GetMapping("/userPage")
    public Result<Page> userPage(int page, int pageSize) {
        return orderService.userPage(page, pageSize);
    }

    @PostMapping("/submit")
    public Result<String> submit(@RequestBody Order order) {
        return orderService.submit(order);
    }


    @PostMapping("/again")
    public Result<String> again(@RequestBody OrderDTO orderDTO) {
        return orderService.again(orderDTO);
    }

}
